Skip to content

Conversation

phst
Copy link
Contributor

@phst phst commented Aug 18, 2025

These warnings appear if there are no Python source files in the instrumented directories,
cf. #2762.

Work towards #2762

@phst phst requested review from aignas and rickeylev as code owners August 18, 2025 07:43
These warnings appear if there are no Python source files in the
instrumented directories,
cf. bazel-contrib#2762.

Work towards bazel-contrib#2762
@rickeylev
Copy link
Collaborator

Thanks for the PR.

I think we can improve it slighty by using ctx.coverage_instrumented() and ctx.configuration.coverage_enabled. If coverage is enabled and the target isn't instrumented, then disable those warnings. Then we get the best of both worlds: if we expect coverage results, but nothing was generated, then an error (something went wrong). If we don't expect coverage data, then we can ignore it missing.

So what you'll want to do is:

  • Add a template variable to the top of the files. You should see some %blabla% markers near the top of other things. COVERAGE_INSTRUMENTED = "%coverage_instrumented%" == "1"
  • Conditionally add the disable_warnings = ... if that variable is true
  • In py_executable.bzl, pass along an additional key in the template dict. grep for %python_binary%, you should find a couple dicts in the stage1_bootstrap and stage2_bootstrap functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants